$(function () {
    var form = layui.form
    let id = new URLSearchParams(location.search).get('id')
    function loadUserInfo () {
      $.ajax({
        type: 'get',
        url: 'admin/users/' + id,
        success: function (res) {
          if (res.status === 0) {
            form.val('editForm', res.data)
          } else {
            layer.msg(res.message)
          }
        }
      })
    }
    loadUserInfo()
    $('.layui-form').submit(function (e) {
      e.preventDefault()
      var fd = $(this).serialize()
      $.ajax({
        type: 'put',
        url: 'admin/users',
        data: fd,
        success: function (res) {
          layer.msg(res.message)
        }
      })
    })
  
  })